package at.irian.jsfatwork.jsf;

import at.irian.jsfatwork.domain.TaskStatus;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;

/**
 * @author Thomas Spiegl, IRIAN Solutions GmbH
 */
public class TaskStatusEnumConverter implements Converter {
    public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException {
        return value;
    }

    public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException {
        if (value instanceof String)
            return (String) value;
        return value != null ? ((TaskStatus) value).toString() : null;
    }
}
